a tool for shared writing and social publishing
1import { makeRouter } from "../lib";
2import { push } from "./push";
3import { createClient } from "@supabase/supabase-js";
4import { Database } from "supabase/database.types";
5import { pull } from "./pull";
6import { getFactsFromHomeLeaflets } from "./getFactsFromHomeLeaflets";
7import { Vercel } from "@vercel/sdk";
8import {
9 get_domain_status,
10 get_leaflet_subdomain_status,
11} from "./domain_routes";
12import { get_leaflet_data } from "./get_leaflet_data";
13import { get_publication_data } from "./get_publication_data";
14import { search_publication_names } from "./search_publication_names";
15import { search_publication_documents } from "./search_publication_documents";
16import { get_profile_data } from "./get_profile_data";
17import { get_user_recommendations } from "./get_user_recommendations";
18import { get_hot_feed } from "./get_hot_feed";
19import { get_document_interactions } from "./get_document_interactions";
20
21let supabase = createClient<Database>(
22 process.env.NEXT_PUBLIC_SUPABASE_API_URL as string,
23 process.env.SUPABASE_SERVICE_ROLE_KEY as string,
24);
25
26const VERCEL_TOKEN = process.env.VERCEL_TOKEN;
27const vercel = new Vercel({
28 bearerToken: VERCEL_TOKEN,
29});
30const Env = {
31 supabase,
32 vercel,
33};
34export type Env = typeof Env;
35export type Routes = typeof Routes;
36let Routes = [
37 push,
38 pull,
39 getFactsFromHomeLeaflets,
40 get_domain_status,
41 get_leaflet_subdomain_status,
42 get_leaflet_data,
43 get_publication_data,
44 search_publication_names,
45 search_publication_documents,
46 get_profile_data,
47 get_user_recommendations,
48 get_hot_feed,
49 get_document_interactions,
50];
51export async function POST(
52 req: Request,
53 { params }: { params: Promise<{ command: string }> },
54) {
55 let p = await params;
56 let router = makeRouter(Routes);
57 return router(p.command, req, Env);
58}